﻿@{
    ViewBag.Title = "预约医生";
}
@model  List<zqdn.Web.ViewModels.HosCenter.HosAppointViewModel>
<div class="wrap">

    <div class="doctor-assist-page common-list">
        <div class="list-data">
            <ul>
                <li class="items" id="left">
                    <div>
                        <img class="list-left-img" src="~/content/images/doc-assist.png" alt="最新手术集锦">
                    </div>
                </li>
                <li class="items" id="center">

                    <div class="nocenter">
                        <p class="title">@Model.LastOrDefault().Name</p>
                        <p class="user-message">
                            <span class="m1"></span>
                            <span class="m3">@Model.LastOrDefault().HosName</span>
                        </p>
                        <p class="view-message">
                            <span class="m1"></span>
                            <span class="m2">擅长</span>
                            <span class="m3">@Model.LastOrDefault().Domain</span>
                        </p>
                    </div>
                </li>
            </ul>

        </div>
    </div>

    <br />
    <div class="doctor-timemgt-page">
        <p class="table-header">手术时间</p>
        <div class="time-tab">
            <table>
                <tbody>
                    @if (Model.FirstOrDefault().TimeGap == null)
                    {
                        <p style='margin: 20px auto;'>暂无可预约时间！</p>
                    }
                    else { 
                    foreach (var item in Model.Where(o =>o.TimeGap!=null))
                    {
                        <tr>
                            <td>@DateTime.Parse(item.TimeGap.ToString()).ToShortDateString()</td>
                            <td>
                                @if (item.Status == -1)
                                {
                                    <a gid="@item.ID" uid="@item.UserID">预约</a>
                                }
                                else
                                {
                                    <span class="m2 @(item.Status == 0 ? "status4" : item.Status == 1 ? "status1" : item.Status == 2 ? "status2" : "status3")">
                                        <i class="fa fa-star"></i>
                                        @switch (item.Status)
                                        {
                                            case 0:
                                            @("已预约")
                                                break;
                                            case 1:
                                            @("预约成功")
                                                <i class="fa fa-file-text-o" style="margin-left: 5px;"></i>
                                                <a typeid="1" style="text-decoration:none;" href="@Url.Action("AppointApply", "HosCenter", new { id=item.InviteID })">上传病例</a>
                                                break;
                                            case 2:
                                         
                                            @("已付定金")
                                                <i class="fa fa-eye" style="margin-left: 5px;"></i>
                                                <a typeid="1" style="text-decoration:none;" href="@Url.Action("OperationVideoDetail", "CommonCenter", new { oid = item.OperationID })">查看手术</a>
                                                break;
                                            case 3:
                                            @("已完成")
                                                <i class="fa fa-eye" style="margin-left: 5px;"></i>
                                                <a typeid="1" style="text-decoration:none;" href="@Url.Action("OperationVideoDetail", "CommonCenter", new { oid = item.OperationID })">查看手术</a>
                                                break;

                                        }
                                    </span>
                                }

                            </td>

                        </tr>
                    }
                    }
                </tbody>
            </table>
        </div>
    </div>

    <script type='text/html' id='appointform'>
        <div>
            <span>手术名称:</span>
            <input type="text" class="form-control" id="opname" style="width:70%;border-radius:3px;border:1px solid #EAEAEA;height:22px;" />
        </div>
    </script>

</div>

@section scripts
{
    <script type="text/javascript">
        $(function () {
            $(".time-tab a").on("click", function () {

                if ($(this).attr("typeid") != 1) {
                    var _gid = $(this).attr("gid");
                    var _uid = $(this).attr("uid");
                    layer.open({
                        content: $("#appointform").html(),
                        btn: ['预约', '取消'],
                        shadeClose: false,
                        yes: function () {
                            $.post("/HosCenter/DoctorGapTime/", { "opname": $("#opname").val(), "gid": _gid, "uid": _uid }, function (data) {
                                var result = "";
                                if (data == 1) {
                                    result = "预约成功，等待医生审核通过！"
                                } else {
                                    result = "预约失败，请稍后再试！"
                                }
                                layer.open({
                                    content: result,
                                    btn: ['确定'],
                                    yes: function () {
                                        location.reload();
                                    }
                                })
                            });
                        }
                    })
                }
                });
          
        });
    </script>
}


